package org.openstreetmap.gui.jmapviewer;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.RenderingHints;
import java.awt.geom.Line2D;

/**
 * Created by: Eduardo Quintana Contreras
 * Date: 11/01/12
 * Time: 05:00 PM
 */
public class MapLine {
	double lat1, lat2;
    double lon1, lon2;
    Color color;

    public MapLine(double lat1, double lon1, double lat2, double lon2) {
        this(new Color(255, 0, 0, 100), lat1, lon1, lat2, lon2);
    }

    public MapLine(Color color, double lat1, double lon1, double lat2, double lon2) {
        this.color = color;
        this.lat1 = lat1;
        this.lon1 = lon1;
	    this.lat2 = lat2;
	    this.lon2 = lon2;
    }

	public double getLat1() {
		return lat1;
	}

	public double getLon1() {
		return lon1;
	}

	public double getLat2() {
		return lat2;
	}

	public double getLon2() {
		return lon2;
	}

	/*public double[] getLat() {
        return new double[]{lat1, lat2};
    }

    public double[] getLon() {
        return new double[]{lon1, lon2};
    }*/

	public void paint(Graphics g, Point position1, Point position2) {
	    Graphics2D g2 = (Graphics2D) g;
		g2.setColor(color);
//		g2.setStroke(new CompositeStroke(new BasicStroke(5f), new BasicStroke(1f)));
		g2.setStroke(new BasicStroke(5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
		g2.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
		g2.draw(new Line2D.Float(position1.x, position1.y, position2.x, position2.y));

//        int size_h = 5;
//        int size = size_h * 2;
//	    Area areaOne = new Area(new Ellipse2D.Double(position.x - size_h, position.y - size_h - 8, size, size));
//	    Polygon triangle = new Polygon();
//	    triangle.addPoint(position.x - 5, position.y - 7);
//	    triangle.addPoint(position.x + 5, position.y - 7);
//	    triangle.addPoint(position.x, position.y);
//	    Area areaTwo = new Area(triangle);
//	    areaOne.add(areaTwo);
//        g2.setMarkerBackground(markerBackground);
//	    g2.fill(areaOne);
//        g2.setMarkerBackground(Color.BLACK);
//	    g2.draw(areaOne);



	    /*int size_h = 5;
        int size = size_h * 2;
        g.setMarkerBackground(markerBackground);
        g.fillOval(position.x - size_h, position.y - size_h, size, size);
        g.setMarkerBackground(Color.BLACK);
        g.drawOval(position.x - size_h, position.y - size_h, size, size);*/
    }

}
